<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/common :: head" />
<body>
  <div th:replace="fragments/common :: bootstrap" />
  <div th:include="fragments/common :: loadBundlesFromDb (${isLoadBundlesFromDb})" />
  <div th:if="${isLoadBundlesFromDb} and ${isAdmin}">
    <div class="portletBody">
      <div id="menu" th:include="fragments/menus :: main (modules)" />
      <h3 th:text="#{modules.modules}">Messages by Module</h3>
      <form id="filterForm" action="#" th:action="@{/modules}" th:object="${modulesFilterEntity}" method="post">
        <label for="moduleSelect" th:text="#{modules.module.select}">Select a Module</label>
        <select id="moduleSelect" th:field="*{module}">
          <option th:each="module : ${listMessagePropertyModules}" th:value="${module}" th:text="${module}">module</option>
        </select>
        <label for="localeSelect" th:text="#{modules.locale.select}">Select a Locale</label>
        <select id="localeSelect" th:field="*{locale}">
          <option th:each="locale : ${listMessagePropertyLocales}" th:value="${locale}" th:text="${locale}">locale</option>
        </select>
        <button class="btn-link" type="submit" name="filter" th:text="#{modules.filter}">Filter</button>
      </form>
      <div th:switch="${ #lists.isEmpty(properties) }">
        <div th:case="true">
          <div class="sak-banner-info" role="alert" th:text="#{modules.info}">Please select a module and a locale from the drop down lists above, and then click Filter.</div>
        </div>
        <div th:case="false">
          <table id="modulesTable" class="table table-striped table-bordered dataTable">
            <thead>
              <tr>
                <th class="no-sort"></th>
                <th th:text="#{mbp.id}">Id</th>
                <th th:text="#{mbp.moduleName}">Module Name</th>
                <th th:text="#{mbp.propertyName}">Property Name</th>
                <th th:text="#{mbp.value}">Value</th>
                <th th:text="#{mbp.defaultValue}">Default Value</th>
                <th th:text="#{mbp.locale}">Locale</th>
              </tr>
            </thead>
            <tbody>
              <tr th:each="property : ${properties}">
                <td><a href="edit" class="btn btn-default btn-xs btn-block" role="button" th:href="@{/edit(id=${property?.id})}" th:text="#{modules.edit}">Edit</a></td>
                <td th:text="${property?.id}">0</td>
                <td th:text="${property?.moduleName}">moduleName</td>
                <td th:text="${property?.propertyName}">propertyName</td>
                <td th:text="${property?.value}">value</td>
                <td th:text="${property?.defaultValue}">defaultValue</td>
                <td th:text="${property?.locale}">locale</td>
              </tr>
            </tbody>
          </table>
          <script>includeWebjarLibrary('datatables');</script>
          <script th:inline="javascript">
            $(document).ready(function () {
              $('#modulesTable').DataTable({
                "order": [],
                "columnDefs": [{
                  "targets": 'no-sort',
                  "orderable": false,
                }]
              });
            });
          </script>
        </div>
      </div>
    </div>
  </div>
</body>
</html>